/*
  FileName : UART.h
  Create on 2009.3.2 by ZZP.

  Revision History:

*/

#ifndef __UART_H__
#define _UART_H__

#define Pub_BufCntMask   3
#define Pub_OneBufMask   0x7F


typedef struct{
  //
  Uns Port;
  Uns BufCntMask;
  Uns OneBufLen;
  Uns RemainLen;
  Uns *BufBaseAddr;
  //
  volatile Uns Index;
  volatile Uns HandleIndex;
  Uns *TxPtr;
  Uns TxTm;
  Uns TxFlag;
}UART_PORT_INFO, *pUART_PORT_INFO;

typedef struct{
  Uns Port;
  Uns StartF;
  Uns Cnt;
  Uns DLE;
  Uns *DestBaseAddr;
  Uns Index;
  Uns HandleIndex;
  Uns BufCntMask;
  Uns OneBufLen;
  Uns RxTm;
  Uns RxFlag;
}UART_RX_INFO, *pUART_RX_INFO;
//////////////////////////////////////////////////////////
//  UART Tx variables:
//////////////////////////////////////////////////////////
extern UART_PORT_INFO PubPortInfo;
extern Uns Pub_TxBuf[Pub_BufCntMask + 1][Pub_OneBufMask + 1]; 

extern void Sci_InitPort(void);
extern void IncIndex(Uns *Index, Uns MaxMask);
extern Uns Sci_TxData(UART_PORT_INFO *PortInfo);
extern Uns Sci_RxData(UART_RX_INFO *RxPortInfo);
extern Uns Sci_InqueryRxData(Uns SciPort, Uns *Dest);
extern Uns Sci_InqueryTxReady(Uns SciPort);


#endif


